package com.ungao.tools.generator.util;

import java.io.File;

public class PathUtil {

    /**
     * 系统文件分割符
     */
    public static final String separator = File.separator;

    /**
     * 斜线 '/'
     */
    public static final String SLANT = "/";

    /**
     * java文件
     */
    public static final String JAVA = ".java";

    /**
     * xml文件
     */
    public static final String XML = ".xml";

    /**
     * 字符串连接
     *
     * @param strings
     * @return
     */
    public static String concatToPath(String... strings) {
        StringBuilder sb = new StringBuilder();
        for (String content : strings) {
            if (content != null && content != "") {
                sb.append(content);
            }
        }
        return sb.toString();
    }

    /**
     * 路径转换
     *
     * @param path
     * @return
     */
    public static String convertPath(String path) {
        StringBuilder sb = new StringBuilder(path);
        if (!path.endsWith(SLANT)) {
            sb.append(SLANT);
        }
        return sb.toString();
    }

    /**
     * 创建目录
     *
     * @param path
     */
    public static String createPath(String path) {
        File testFile = new File(path);
        if (!testFile.exists()) {
            testFile.mkdirs();
        }
        return path;
    }

}
